<?php
$this->breadcrumbs = array(
	'Quản lý Sự kiện' => array('/Events/default/index'),
    'Đăng sự kiện'
);
?>
<!-- BEGIN PORTLET-->
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'event-form',
	'enableClientValidation'=>false,
	'clientOptions'=>array(
		'validateOnSubmit'=>false,
	),
	'htmlOptions'=>array(
		'class'=>'',
		'enctype'=>'multipart/form-data'
	),
)); ?>
<?php $countries = array("Việt Nam" => "Việt Nam", "Afghanistan" => "Afghanistan", "Albania" => "Albania", "Algeria" => "Algeria", "American Samoa" => "American Samoa", "Andorra" => "Andorra", "Angola" => "Angola", "Anguilla" => "Anguilla", "Antarctica" => "Antarctica", "Antigua and Barbuda" => "Antigua and Barbuda", "Argentina" => "Argentina", "Armenia" => "Armenia", "Aruba" => "Aruba", "Australia" => "Australia", "Austria" => "Austria", "Azerbaijan" => "Azerbaijan", "Bahamas" => "Bahamas", "Bahrain" => "Bahrain", "Bangladesh" => "Bangladesh", "Barbados" => "Barbados", "Belarus" => "Belarus", "Belgium" => "Belgium", "Belize" => "Belize", "Benin" => "Benin", "Bermuda" => "Bermuda", "Bhutan" => "Bhutan", "Bolivia" => "Bolivia", "Bosnia and Herzegovina" => "Bosnia and Herzegovina", "Botswana" => "Botswana", "Bouvet Island" => "Bouvet Island", "Brazil" => "Brazil", "British Indian Ocean Territory" => "British Indian Ocean Territory", "Brunei Darussalam" => "Brunei Darussalam", "Bulgaria" => "Bulgaria", "Burkina Faso" => "Burkina Faso", "Burundi" => "Burundi", "Cambodia" => "Cambodia", "Cameroon" => "Cameroon", "Canada" => "Canada", "Cape Verde" => "Cape Verde", "Cayman Islands" => "Cayman Islands", "Central African Republic" => "Central African Republic", "Chad" => "Chad", "Chile" => "Chile", "China" => "China", "Christmas Island" => "Christmas Island", "Cocos (Keeling) Islands" => "Cocos (Keeling) Islands", "Colombia" => "Colombia", "Comoros" => "Comoros", "Congo" => "Congo", "Congo, The Democratic Republic of The" => "Congo, The Democratic Republic of The", "Cook Islands" => "Cook Islands", "Costa Rica" => "Costa Rica", "Cote D'ivoire" => "Cote D'ivoire", "Croatia" => "Croatia", "Cuba" => "Cuba", "Cyprus" => "Cyprus", "Czech Republic" => "Czech Republic", "Denmark" => "Denmark", "Djibouti" => "Djibouti", "Dominica" => "Dominica", "Dominican Republic" => "Dominican Republic", "Ecuador" => "Ecuador", "Egypt" => "Egypt", "El Salvador" => "El Salvador", "Equatorial Guinea" => "Equatorial Guinea", "Eritrea" => "Eritrea", "Estonia" => "Estonia", "Ethiopia" => "Ethiopia", "Falkland Islands (Malvinas)" => "Falkland Islands (Malvinas)", "Faroe Islands" => "Faroe Islands", "Fiji" => "Fiji", "Finland" => "Finland", "France" => "France", "French Guiana" => "French Guiana", "French Polynesia" => "French Polynesia", "French Southern Territories" => "French Southern Territories", "Gabon" => "Gabon", "Gambia" => "Gambia", "Georgia" => "Georgia", "Germany" => "Germany", "Ghana" => "Ghana", "Gibraltar" => "Gibraltar", "Greece" => "Greece", "Greenland" => "Greenland", "Grenada" => "Grenada", "Guadeloupe" => "Guadeloupe", "Guam" => "Guam", "Guatemala" => "Guatemala", "Guinea" => "Guinea", "Guinea-bissau" => "Guinea-bissau", "Guyana" => "Guyana", "Haiti" => "Haiti", "Heard Island and Mcdonald Islands" => "Heard Island and Mcdonald Islands", "Holy See (Vatican City State)" => "Holy See (Vatican City State)", "Honduras" => "Honduras", "Hong Kong" => "Hong Kong", "Hungary" => "Hungary", "Iceland" => "Iceland", "India" => "India", "Indonesia" => "Indonesia", "Iran, Islamic Republic of" => "Iran, Islamic Republic of", "Iraq" => "Iraq", "Ireland" => "Ireland", "Israel" => "Israel", "Italy" => "Italy", "Jamaica" => "Jamaica", "Japan" => "Japan", "Jordan" => "Jordan", "Kazakhstan" => "Kazakhstan", "Kenya" => "Kenya", "Kiribati" => "Kiribati", "Korea, Democratic People's Republic of" => "Korea, Democratic People's Republic of", "Korea, Republic of" => "Korea, Republic of", "Kuwait" => "Kuwait", "Kyrgyzstan" => "Kyrgyzstan", "Lao People's Democratic Republic" => "Lao People's Democratic Republic", "Latvia" => "Latvia", "Lebanon" => "Lebanon", "Lesotho" => "Lesotho", "Liberia" => "Liberia", "Libyan Arab Jamahiriya" => "Libyan Arab Jamahiriya", "Liechtenstein" => "Liechtenstein", "Lithuania" => "Lithuania", "Luxembourg" => "Luxembourg", "Macao" => "Macao", "Macedonia, The Former Yugoslav Republic of" => "Macedonia, The Former Yugoslav Republic of", "Madagascar" => "Madagascar", "Malawi" => "Malawi", "Malaysia" => "Malaysia", "Maldives" => "Maldives", "Mali" => "Mali", "Malta" => "Malta", "Marshall Islands" => "Marshall Islands", "Martinique" => "Martinique", "Mauritania" => "Mauritania", "Mauritius" => "Mauritius", "Mayotte" => "Mayotte", "Mexico" => "Mexico", "Micronesia, Federated States of" => "Micronesia, Federated States of", "Moldova, Republic of" => "Moldova, Republic of", "Monaco" => "Monaco", "Mongolia" => "Mongolia", "Montserrat" => "Montserrat", "Morocco" => "Morocco", "Mozambique" => "Mozambique", "Myanmar" => "Myanmar", "Namibia" => "Namibia", "Nauru" => "Nauru", "Nepal" => "Nepal", "Netherlands" => "Netherlands", "Netherlands Antilles" => "Netherlands Antilles", "New Caledonia" => "New Caledonia", "New Zealand" => "New Zealand", "Nicaragua" => "Nicaragua", "Niger" => "Niger", "Nigeria" => "Nigeria", "Niue" => "Niue", "Norfolk Island" => "Norfolk Island", "Northern Mariana Islands" => "Northern Mariana Islands", "Norway" => "Norway", "Oman" => "Oman", "Pakistan" => "Pakistan", "Palau" => "Palau", "Palestinian Territory, Occupied" => "Palestinian Territory, Occupied", "Panama" => "Panama", "Papua New Guinea" => "Papua New Guinea", "Paraguay" => "Paraguay", "Peru" => "Peru", "Philippines" => "Philippines", "Pitcairn" => "Pitcairn", "Poland" => "Poland", "Portugal" => "Portugal", "Puerto Rico" => "Puerto Rico", "Qatar" => "Qatar", "Reunion" => "Reunion", "Romania" => "Romania", "Russian Federation" => "Russian Federation", "Rwanda" => "Rwanda", "Saint Helena" => "Saint Helena", "Saint Kitts and Nevis" => "Saint Kitts and Nevis", "Saint Lucia" => "Saint Lucia", "Saint Pierre and Miquelon" => "Saint Pierre and Miquelon", "Saint Vincent and The Grenadines" => "Saint Vincent and The Grenadines", "Samoa" => "Samoa", "San Marino" => "San Marino", "Sao Tome and Principe" => "Sao Tome and Principe", "Saudi Arabia" => "Saudi Arabia", "Senegal" => "Senegal", "Serbia and Montenegro" => "Serbia and Montenegro", "Seychelles" => "Seychelles", "Sierra Leone" => "Sierra Leone", "Singapore" => "Singapore", "Slovakia" => "Slovakia", "Slovenia" => "Slovenia", "Solomon Islands" => "Solomon Islands", "Somalia" => "Somalia", "South Africa" => "South Africa", "South Georgia and The South Sandwich Islands" => "South Georgia and The South Sandwich Islands", "Spain" => "Spain", "Sri Lanka" => "Sri Lanka", "Sudan" => "Sudan", "Suriname" => "Suriname", "Svalbard and Jan Mayen" => "Svalbard and Jan Mayen", "Swaziland" => "Swaziland", "Sweden" => "Sweden", "Switzerland" => "Switzerland", "Syrian Arab Republic" => "Syrian Arab Republic", "Taiwan, Province of China" => "Taiwan, Province of China", "Tajikistan" => "Tajikistan", "Tanzania, United Republic of" => "Tanzania, United Republic of", "Thailand" => "Thailand", "Timor-leste" => "Timor-leste", "Togo" => "Togo", "Tokelau" => "Tokelau", "Tonga" => "Tonga", "Trinidad and Tobago" => "Trinidad and Tobago", "Tunisia" => "Tunisia", "Turkey" => "Turkey", "Turkmenistan" => "Turkmenistan", "Turks and Caicos Islands" => "Turks and Caicos Islands", "Tuvalu" => "Tuvalu", "Uganda" => "Uganda", "Ukraine" => "Ukraine", "United Arab Emirates" => "United Arab Emirates", "United Kingdom" => "United Kingdom", "United States" => "United States", "United States Minor Outlying Islands" => "United States Minor Outlying Islands", "Uruguay" => "Uruguay", "Uzbekistan" => "Uzbekistan", "Vanuatu" => "Vanuatu", "Venezuela" => "Venezuela", "Viet Nam" => "Viet Nam", "Virgin Islands, British" => "Virgin Islands, British", "Virgin Islands, U.S." => "Virgin Islands, U.S.", "Wallis and Futuna" => "Wallis and Futuna", "Western Sahara" => "Western Sahara", "Yemen" => "Yemen", "Zambia" => "Zambia", "Zimbabwe" => "Zimbabwe"); ?>
<div class="form-body">
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN Portlet Events-->
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Cài đặt sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="row">
                        <div class="col-xs-2">
                            <div class="form-group">
                                <?php echo $form->labelEx($model, 'featured', array('class'=>'control-label')); ?>
                                <?php echo $form->dropDownList($model,'featured',array('N'=>'Không', 'Y'=>'Có'), array('class'=>'form-control input-sm')); ?>
                                <span class="help-block text-danger"><?php echo $form->error($model, 'featured'); ?></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-7">
            <!-- BEGIN Portlet Events-->
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Thông tin sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-group">
                        <?php echo $form->labelEx($model, 'title', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model, 'title', array('class'=>'form-control input-sm', 'placeholder'=>'Điền tên sự kiện của bạn')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($model, 'title'); ?></span>
                    </div>
                    <div class="form-group row">
                        <div class="col-xs-6">
                            <?php echo $form->labelEx($category, 'category_id', array('class'=>'control-label')); ?>
                            <?php echo $form->dropDownList($category,'category_id',CHtml::listData(Categories::model()->findAll(),'id','title', 'category.title'), array('class'=>'form-control input-sm')); ?>
                            <span class="help-block text-danger"><?php echo $form->error($category, 'category_id'); ?></span>
                        </div>
                        <div class="col-xs-6">
                            <?php echo $form->labelEx($model, 'ticket', array('class'=>'control-label')); ?>
                            <?php echo $form->dropDownList($model,'ticket', array('F'=>'Miễn phí', 'P'=>'Có phí', 'G'=>'Ưu đãi'), array('class'=>'form-control input-sm')); ?>
                            <span class="help-block text-danger"><?php echo $form->error($model, 'ticket'); ?></span>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <?php echo $form->labelEx($model, 'brief', array('class'=>'control-label')); ?>
                        <?php echo $form->textArea($model, 'brief', array('class'=>'form-control input-sm', 'placeholder'=>'Mô tả nội dung sự kiện của bạn', 'rows'=>5)); ?>
                        <span class="help-block text-danger"><?php echo $form->error($model, 'brief'); ?></span>
                    </div>
                </div>
            </div>
            
            <!-- BEGIN Portlet SeoTool-->
            <div class="portlet box red">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Thông tin SEO</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a id="add-seo" href="javascript:;" class="btn blue btn-sm"><i class="icon-pencil"></i> Copy</a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-group">
                        <?php echo $form->labelEx($seotool, 'title', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($seotool, 'title', array('class'=>'form-control input-sm', 'placeholder'=>'')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($seotool, 'title'); ?></span>
                    </div>
                    
                    <div class="form-group">
                        <?php echo $form->labelEx($seotool, 'description', array('class'=>'control-label')); ?>
                        <?php echo $form->textArea($seotool, 'description', array('class'=>'form-control input-sm', 'placeholder'=>'', 'rows'=>5)); ?>
                        <span class="help-block text-danger"><?php echo $form->error($seotool, 'description'); ?></span>
                    </div>
                    
                    <div class="form-group">
                        <?php echo $form->labelEx($seotool, 'keywords', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($seotool, 'keywords', array('class'=>'form-control input-sm', 'placeholder'=>'')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($seotool, 'keywords'); ?></span>
                    </div>
                </div>
            </div>
            <!-- END Portlet PORTLET-->
        </div>
        <div class="col-md-5">
            <!-- BEGIN Portlet Event image-->
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Ảnh sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="fileupload fileupload-new <?php echo ($model->getError('image') ? 'has-error' : ''); ?>" data-provides="fileupload">
                        <div class="fileupload-new thumbnail" style="width: 100%;">
                        <?php if ($model->isNewRecord) : ?>
                            <img src="<?php echo Yii::app()->theme->baseUrl; ?>/img/no_image.gif" alt="" />
                        <?php else : ?>
                            <img src="<?php echo $this->getImageUrl() . 'events/primary/' . date('Ymd', strtotime($model->posteddate)) . '/' . $model->image; ?>" alt="" />
                        <?php endif; ?>
                        </div>
                        <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100%; line-height: 20px;"></div>
                        <div class="text-center">
                            <span class="btn default btn-file">
                                <span class="fileupload-new"><i class="icon-paper-clip"></i> Select image</span>
                                <span class="fileupload-exists"><i class="icon-undo"></i> Change</span>
                                <?php echo $form->fileField($model, 'image', array('class'=>'default')); ?>
                            </span>
                            <a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="icon-trash"></i> Remove</a>
                        </div>
                        <?php echo $form->error($model, 'image', array('class'=>'help-block')); ?>
                    </div>
                </div>
            </div>
            
            <!-- BEGIN Portlet EventCharts-->
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Sơ đồ chỗ ngồi</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="fileupload fileupload-new <?php echo ($model->getError('image') ? 'has-error' : ''); ?>" data-provides="fileupload">
                        <div class="fileupload-new thumbnail" style="width: 100%;">
                        <?php if ($model->isNewRecord) : ?>
                            <img src="<?php echo Yii::app()->theme->baseUrl; ?>/img/no_image.gif" alt="" />
                        <?php else : ?>
                            <img src="<?php echo $this->getImageUrl() . 'events/primary/' . date('Ymd', strtotime($model->posteddate)) . '/' . $model->image; ?>" alt="" />
                        <?php endif; ?>
                        </div>
                        <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100%; line-height: 20px;"></div>
                        <div class="text-center">
                            <span class="btn default btn-file">
                                <span class="fileupload-new"><i class="icon-paper-clip"></i> Select image</span>
                                <span class="fileupload-exists"><i class="icon-undo"></i> Change</span>
                                <?php echo $form->fileField($chart, 'image', array('class'=>'default')); ?>
                            </span>
                            <a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="icon-trash"></i> Remove</a>
                        </div>
                        <?php echo $form->error($model, 'image', array('class'=>'help-block')); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-7">
            <!-- Event Location -->
            <div class="portlet box red">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Địa điểm sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-group">
                        <?php echo $form->textField($location, 'title', array('class'=>'form-control input-sm', 'placeholder'=>'Tên địa điểm')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($location, 'title'); ?></span>
                    </div>
                    <div class="form-group">
                        <?php echo $form->textField($location, 'address', array('class'=>'form-control input-sm', 'placeholder'=>'Địa chỉ')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($location, 'address'); ?></span>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <?php echo $form->textField($location, 'ward', array('class'=>'form-control input-sm', 'placeholder'=>'Phường/Xã')); ?>
                                <span class="help-block text-danger"><?php echo $form->error($location, 'ward'); ?></span>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <?php echo $form->textField($location, 'district', array('class'=>'form-control input-sm', 'placeholder'=>'Quận/Huyện')); ?>
                                <span class="help-block text-danger"><?php echo $form->error($location, 'district'); ?></span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <?php echo $form->textField($location, 'city', array('class'=>'form-control input-sm', 'placeholder'=>'Tỉnh/Thành phố')); ?>
                                <span class="help-block text-danger"><?php echo $form->error($location, 'city'); ?></span>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <?php echo $form->dropDownList($location, 'country', $countries, array('class'=>'form-control input-sm')); ?>
                                <span class="help-block text-danger"><?php echo $form->error($location, 'title'); ?></span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <div class="col-md-3 col-pad-right">
                                <span class="help-block">Start Date</span>
                                <div class="input-group date date-picker" data-date="<?php echo date('d-m-Y', strtotime($model->startdate)); ?>" data-date-format="dd-mm-yyyy">
                                    <input type="text" class="form-control" readonly id="startdate" name="startdate" value="<?php echo date('d-m-Y', strtotime($model->startdate)); ?>">
                                    <span class="input-group-btn">
                                    <button class="btn default" type="button"><i class="icon-calendar"></i></button>
                                    </span>
                                 </div>
                            </div>
                            
                            <div class="col-md-3">
                                <span class="help-block">Start Time</span>
                                <div class="input-group bootstrap-timepicker">
                                    <input type="text" class="form-control timepicker-default" id="starttime" name="starttime" value="<?php echo date('H:i', strtotime($model->startdate)); ?>" readonly>
                                    <span class="input-group-btn">
                                    <button class="btn default" type="button"><i class="icon-time"></i></button>
                                    </span>
                                </div>
                            </div>
                            
                            <div class="col-md-3 col-pad-right">
                                <span class="help-block">End Date</span>
                                <div class="input-group date date-picker" data-date="<?php echo date('d-m-Y', strtotime($model->enddate)); ?>" data-date-format="dd-mm-yyyy">
                                    <input type="text" class="form-control" readonly id="enddate" name="enddate" value="<?php echo date('d-m-Y', strtotime($model->enddate)); ?>">
                                    <span class="input-group-btn">
                                    <button class="btn default" type="button"><i class="icon-calendar"></i></button>
                                    </span>
                                 </div>
                            </div>
                            
                            <div class="col-md-3">
                                <span class="help-block">End Time</span>
                                <div class="input-group bootstrap-timepicker">
                                    <input type="text" class="form-control timepicker-default" id="endtime" name="endtime" value="<?php echo date('H:i', strtotime($model->enddate)); ?>" readonly>
                                    <span class="input-group-btn">
                                    <button class="btn default" type="button"><i class="icon-time"></i></button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Event Contact -->
            <div class="portlet box red">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Thông tin liên hệ</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a id="add-contact" href="javascript:;" class="btn blue btn-sm"><i class="icon-pencil"></i> Thêm mới</a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div id="form-contact" data-id="0" style="display:none;">
                        <label for="EventContact_title">Thông tin liên hệ</label>
                        <div class="row">
                            <div class="col-md-11">
                                <div class="form-group">
                                    <input type="text" class="form-control input-sm" placeholder="Đơn vị liên lạc" name="EventContact[company][]" id="EventContact[company]" />
                                    <span class="help-block text-danger"><?php echo $form->error($contact, 'company'); ?></span>
                                </div>
                            </div>
                            <div class="col-xs-1 col-pad-left contact-button">
                                <a class="btn btn-default btn-block" data-id="0">Xóa</a>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-2">
                                <div class="form-group">
                                    <select name="EventContact[prename][]" id="EventContact[prename]" class="form-control input-sm">
                                        <option value="Mr.">Mr.</option>
                                        <option value="Miss.">Miss.</option>
                                        <option value="Mrs.">Mrs.</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-5">
                                <div class="form-group">
                                    <input type="text" class="form-control input-sm" placeholder="Họ và tên" name="EventContact[fullname][]" id="EventContact[fullname]" />
                                </div>
                            </div>
                            <div class="col-md-5">
                                <div class="form-group">
                                    <input type="text" class="form-control input-sm" placeholder="Số điện thoại" name="EventContact[phone][]" id="EventContact[phone]" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-5">
            <!-- Event Tags -->
            <div class="portlet box red">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Tags sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-group">
                        <?php echo $form->hiddenField($label, 'title', array('class'=>'form-control select2 input-sm', 'value'=>Yii::app()->session['tags'])); ?>
                    </div>
                </div>
            </div>
            
            <!-- Event Tickets -->
            <div class="portlet box red" id="ticket-content" style="display:none;">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Thông tin vé sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a id="add-ticket" href="javascript:;" class="btn blue btn-sm"><i class="icon-pencil"></i> Thêm mới</a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div id="form-ticket" data-id="0" style="display:none;">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <input type="text" class="form-control input-sm" placeholder="Loại vé" name="EventTickets[title][]" id="EventTickets[title]" />
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <div class="input-group">
                                       <input type="text" class="form-control input-sm text-right" placeholder="Giá vé" name="EventTickets[price][]" id="EventTickets[price]" />
                                       <span class="input-group-addon">VNĐ</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-2 col-pad-left ticket-button">
                                <a class="btn btn-default btn-block" data-id="0">Xóa</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN Portlet EventContent-->
            <div class="portlet box red">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>Nội dung sự kiện</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-group">
                        <?php echo $form->labelEx($content, 'description', array('class'=>'control-label')); ?>
                        <?php $this->widget('application.extensions.ckeditor.CKEditor', array(
                            'model'=>$content,
                            'attribute'=>'description',
                            'language'=>'vi',
                            'editorTemplate'=>'full',
                            'options'=>array(
                                'height'=>'600px',
                            ),
                            'htmlOptions'=>array('rows'=>20,'class'=>'form-control'),
                        )); ?>
                        <span class="help-block text-danger"><?php echo $form->error($content, 'description'); ?></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="portlet box">
            <div class="portlet-body form">
                <div class="form-actions fluid">
                    <div class="text-right">
                        <button type="submit" class="btn blue" onclick="Custom.showLoading();"><i class="icon-ok"></i> Đăng sự kiện</button>
                        <button type="button" class="btn default">Cancel</button>                              
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->endWidget(); ?>
<script type="text/javascript">
$(document).ready(function(e) {
    $('#add-seo').on('click', function(){
        $('#SeoTools_title').val($('#Events_title').val());
        $('#SeoTools_description').val($('#Events_brief').val());
    });

    $('.date-picker').datepicker({
        autoclose: true
    });
    
    $('#starttime').timepicker({
        defaultTime: '<?php echo date('H:i', strtotime($model->startdate)); ?>',
		showMeridian: false,
        autoclose: true
    });
    
    $('#endtime').timepicker({
        defaultTime: '<?php echo date('H:i', strtotime($model->enddate)); ?>',
		showMeridian: false,
        autoclose: true
    });
	
	// Ticket form
	$('#Events_ticket').on('change', function(){
		var ticket = $(this).val();
		if (ticket != 'F') {
			$('#ticket-content').fadeIn();
		}
		else {
			$('#ticket-content').hide();
		}
	});
	var totalTicket = $('.form-ticket').size();
	$('#add-ticket').on('click', function(){
		var form = $('#form-ticket').html();
		var count = $('#form-ticket').data('id');
		if (totalTicket < 10) {
			$('#form-ticket').before('<div class="form-ticket" id="ticket-'+(count+1)+'">'+form+'</div>').data('id', (count+1));
			totalTicket++;
			$('#ticket-'+(count+1)+' .ticket-button a').data('id', count+1);
			
			$('#ticket-'+(count+1)+' .ticket-button a').on('click', function() {
				var id = $(this).data('id');
				if (confirm('Bạn muốn xóa vé này đi?')) {
					$('#ticket-'+id).fadeOut().remove();
					totalTicket--;
				}
			});
		}
	});
	// Delete ticket
	$('.ticket-button a').on('click', function() {
		var id = $(this).data('id');
		if (confirm('Bạn muốn xóa vé này đi?')) {
			$('#ticket-'+id).fadeOut().remove();
			totalTicket--;
		}
	});
	
	// Contact form
	var totalContact = $('.form-contact').size();
	$('#add-contact').on('click', function(){
		var form = $('#form-contact').html();
		var count = $('#form-contact').data('id');
		if (totalContact < 4) {
			$('#form-contact').after('<div class="form-contact" id="contact-'+(count+1)+'">'+form+'</div>').data('id', (count+1));
			totalContact++;
			
			$('#contact-'+(count+1)+' .contact-button a').data('id', count+1);
			
			$('#contact-'+(count+1)+' .contact-button a').on('click', function() {
				var id = $(this).data('id');
				if (confirm('Bạn muốn xóa liên hệ này đi?')) {
					$('#contact-'+id).fadeOut().remove();
					totalContact--;
				}
			});
		}
	});
	// Delete contact
	$('.contact-button a').on('click', function() {
		var id = $(this).data('id');
		if (confirm('Bạn muốn xóa liên hệ này đi?')) {
			$('#contact-'+id).fadeOut().remove();
			totalContact--;
		}
	});
	
	// Add contact form
	var form = $('#form-contact').html();
	var count = $('#form-contact').data('id');
	if (totalContact < 4) {
		$('#form-contact').after('<div class="form-contact" id="contact-'+(count+1)+'">'+form+'</div>').data('id', (count+1));
		totalContact++;
		
		$('#contact-'+(count+1)+' .contact-button a').data('id', count+1);
		
		$('#contact-'+(count+1)+' .contact-button a').on('click', function() {
			var id = $(this).data('id');
			if (confirm('Bạn muốn xóa liên hệ này đi?')) {
				$('#contact-'+id).fadeOut();
				totalContact--;
			}
		});
	}
    
    $("#Labels_title").select2({
        tags: true,
        minimumInputLength: 2,
        tokenSeparators: [","],
        initSelection : function (element, callback) {
            var data = [];
            $(element.val().split(',')).each(function(i) {
                var item = this.split(':');
                data.push({
                    id: item[0],
                    text: item[1]
                });
            });
            element.val('');
            callback(data);
        },
        createSearchChoice: function(term, data) {
            if ($(data).filter(function() {
                return this.text.localeCompare(term) === 0;
            }).length === 0) {
                return {
                    id: term,
                    text: term
                };
            }
        },
        multiple: true,
        ajax: {
            url: '<?php echo Yii::app()->createUrl('/Events/request/suggestTag'); ?>',
            dataType: "json",
            data: function(term, page) {
                return {
                    q: term
                };
            },
            results: function(data, page) {
                return {
                    results: data
                };
            }
        }
    });
});

</script>